package com.itheima.support;

import lombok.Data;

@Data
public class Result<T> {

    private Integer status=200;//状态200，或500

    private boolean flag=true;//true=接口调用成功，false=接口调用失败

    private T data;//真实的接口返回数据

    private String errorMsg;//错误的描述信息




    public Result(T data){
        this.data=data;

    }

    public Result(boolean flag,String errorMsg){
        this.flag=flag;
        this.errorMsg=errorMsg;

    }

    /**
     * 成功
     * @param data
     * @param <T>
     * @return
     */
    public static <T>Result<T>build(T data){
        return new Result<>(data);
    }
    /**
     * 失败
     * */
    public static <T>Result<T>buildError(String errorMsg){
        return new Result<T>(false,errorMsg);
    }

}
